var Birthday = {
	
	init:function () {

		var todaysDate = new Date();
		var month = prompt ("Vilken månad fyller du år (1-12)?", "");
		month = parseInt(month)-1;
		
		var day = prompt ("Vilket datum fyller du år (1-31)", "");
		day = parseInt (day);
		
		
		if (month < todaysDate.getMonth())
		{
			var year = todaysDate.getFullYear()+1;
		}
			
		else
		{
			var year = todaysDate.getFullYear();	
		}
		
		if (day < todaysDate.getDate() && month == todaysDate.getMonth())
		{
			year+=1
		}
		
		if (day == todaysDate.getDate() && month == todaysDate.getMonth())
		{
			
			alert ("GRATTIS");
		}
		
		
		birthday = new Date (year, month, day);
		difference = birthday.getTime() - todaysDate.getTime();
		difference = difference / (1000*60*60*24);
		
		alert("Det är "+ Math.round(difference) + " dagar kvar till din födelsedag ("+ birthday.toDateString());
		

  }
    
};
window.onload = Birthday.init;
